package com.hd.appcommon.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hd.hdxgddcommon.utils.tree.BaseTree;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 权限
 * </p>
 *
 * @author administrator
 * @since 2020-11-26
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class Privilege implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "privilege_id", type = IdType.INPUT)
    private String privilegeId;

    /**
     * 名称
     */
    private String privilegeName;

    private String privilegeKey;

    /**
     * 链接地址
     */
    private String privilegeUrl;

    private Integer privilegeType;

    private Integer privilegeRank;

    private String privilegeIcon;

    private String privilegeDesc;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createDate;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date modifyDate;

    private String parentId;

    /**
     * 状态:1首页展示2请求过滤
     */
    private Integer deletable;


    public BaseTree toBaseTree() {
        BaseTree baseTree = new BaseTree();
        baseTree.setId(this.getPrivilegeId());
        baseTree.setKey(this.getPrivilegeKey());
        baseTree.setIcon(this.getPrivilegeIcon());
        baseTree.setLabel(this.getPrivilegeName());
        baseTree.setParentId(this.getParentId());
        return baseTree;
    }

}
